home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
9-Digit Zip Code Directory
/
9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO
/
z4src.zip
/
BSVOLLBL.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-05-31
|
3KB
|
114 lines
//----------------------------------------------------------------------------
// MODULE DESCRIPTION
//
// Module: bsvollbl.c
// Title: Base Library
// Notice: Copyright (c) 1991-1993, John Weeder, All Rights Reserved.
// Copyright (c) 1993. All rights reserved.
// This module contains proprietary information and should be
// treated as confidential.
//
//----------------------------------------------------------------------------
// MAINTENANCE HISTORY
//
// $Workfile$
// $Revision$
// $Author$
// $Date$
// $Log$
//
//----------------------------------------------------------------------------
// MODULE NARRATIVE
//
//
// This module contains to read the volume label of a drive. This code is only
// valid under DOS or OS/2.
//
// The code in this module should be written entirely in C.
// Do not use any C++ constructs.
//
// This module is portable to:
// DOS 3.X+
// MS Windows 3.X+
// OS/2 2.X+
// OS/2 2.0 PM
// SCO UNIX.
//
// The following compilers are supported:
// MSC 6.0A
// MSC/C++ 7.0
// Borland C++ 3.1 for DOS
// Borland C++ 1.0 for OS/2 2.X
// SCO UNIX cc
//
//----------------------------------------------------------------------------
#include <bs.h>
//----------------------------------------------------------------------------
// Description: Get volume label.
// Parameters: sDrive Drive. 1=A, 2=B,...
// psz Buffer for volume label. Should be at least 14
// bytes in size.
// Returns: TRUE if successful.
//----------------------------------------------------------------------------
BOOL FN_E VolumeLabel(SHORT sDrive, PSZ psz)
{
#if OS_DOS || OS_OS2 || OS_WINDOWS || OS_PM
struct find_t ff;
SHORT sOldDrive = DriveGet();
Assert(psz);
psz[0] = '\0';
if (!DriveSet(sDrive))
return FALSE;
CritErrReset();
if (_dos_findfirst("\\*.*", _A_VOLID, &ff) == 0 && !CritErr())
{
if (strlen(ff.name) > 8)
strcpy(&ff.name[8], &ff.name[9]);
strcpy(psz, ff.name);
return DriveSet(sOldDrive);
}
DriveSet(sOldDrive);
return FALSE;
#else
NOTUSED(sDrive);
Assert(psz);
psz[0] = '\0';
return TRUE;
#endif
}
//----------------------------------------------------------------------------
// Description: Run standard test suite
// Parameters: sTest Test to run.
// 0 Run all default tests (except).
// Returns: TRUE if successful.
//----------------------------------------------------------------------------
#if COMPILE_TEST
BOOL FN VolLblTest(SHORT sTest)
{
CHAR szVolume[14];
SHORT i;
NOTUSED(sTest);
for (i = 'A'; i <= 'Z'; ++i)
{
if (VolumeLabel(i,szVolume))
Output("Volume label of drive %c: is [%s]\n", i, szVolume);
}
return TRUE;
}
#endif
//----------------------------------------------------------------------------
//------------------------------- End of File --------------------------------
//----------------------------------------------------------------------------